# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Daniel Nagy <danielnagy at gmx de>
# Contributor: hauzer <hauzer@gmx.com>

_hkgname=mime-types
pkgname=haskell-mime-types
pkgver=0.1.1.0
pkgrel=1
pkgdesc="Basic mime-type handling types and functions"
url="https://hackage.haskell.org/package/${_hkgname}"
license=('MIT')
arch=('loong64' 'x86_64')
depends=('ghc-libs')
makedepends=('ghc')
source=(https://hackage.haskell.org/packages/archive/${_hkgname}/${pkgver}/${_hkgname}-${pkgver}.tar.gz)
sha512sums=('48fdb8a4284bf89e76a6875399f7faa082f1a3f0d275a23c1761f8265c33081731bebff8549d248bc31dbf789b0f3a96bdd8ca5fb07efb79085ddd156f635f32')

build() {
    cd $_hkgname-$pkgver
    runhaskell Setup configure -O --enable-shared --enable-executable-dynamic --disable-library-vanilla \
        --prefix=/usr --docdir=/usr/share/doc/$pkgname --datasubdir=$pkgname \
        --dynlibdir=/usr/lib --libsubdir=\$compiler/site-local/\$pkgid -fnetwork-uri
    runhaskell Setup build $MAKEFLAGS
    runhaskell Setup register   --gen-script
    runhaskell Setup unregister --gen-script
    sed -i -r -e "s|ghc-pkg.*update[^ ]* |&'--force' |" register.sh
    sed -i -r -e "s|ghc-pkg.*unregister[^ ]* |&'--force' |" unregister.sh
}

package() {
    cd $_hkgname-$pkgver
    
    install -D -m744 register.sh "$pkgdir"/usr/share/haskell/register/$pkgname.sh
    install -D -m744 unregister.sh "$pkgdir"/usr/share/haskell/unregister/$pkgname.sh
    runhaskell Setup copy --destdir="$pkgdir"
    install -D -m644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
    rm -f "$pkgdir"/usr/share/doc/$pkgname/LICENSE
}
